/**
 入驻小区
 **/
(function (vc) {
    vc.extends({
        data: {
            goodCashierCategoryInfo: {
                productCategorys: [],
                productDetails: [],
                curCatelogId: ''
            }
        },
        _initMethod: function () {
            $that._queryProductCategorys();
        },
        _initEvent: function () {
        },
        methods: {
            _queryProductCategorys: function () {
                let _param = {
                    params: {
                        page: 1,
                        row: 50,
                        cateTypes: '2,3',
                        shopId: vc.getCurrentCommunity().shopId
                    }
                }
                //发送get请求
                vc.http.apiGet('/productCategory.queryProductCategory',
                    _param,
                    function (json, res) {
                        var _productCategoryManageInfo = JSON.parse(json);
                        $that.goodCashierCategoryInfo.productCategorys = _productCategoryManageInfo.data;
                        if (_productCategoryManageInfo.data.length > 0) {
                            $that._payCategoryProductDetils(_productCategoryManageInfo.data[0]);
                        }
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _payCategoryProductDetils: function (_productCategory) {
                $that.goodCashierCategoryInfo.curCatelogId = _productCategory.categoryId;
                let _param = {
                    params: {
                        page: 1,
                        row: 50,
                        shopId: vc.getCurrentCommunity().shopId,
                        categoryId: _productCategory.categoryId,
                    }
                }
                //发送get请求
                vc.http.apiGet('/product/queryCashierProductDetail',
                    _param,
                    function (json, res) {
                        var _productCategoryManageInfo = JSON.parse(json);
                        $that.goodCashierCategoryInfo.productDetails = _productCategoryManageInfo.data;
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _loadAddProduct: function (_productDetail) {
                vc.emit('goodCashier', 'chooseProduct', _productDetail);
            },
        }
    });
})(window.vc);
